package cn.luischen.controller;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;

import java.util.ArrayList;

import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.reflect.Whitebox;

import com.alibaba.fastjson.JSON;

import cn.luischen.service.content.ContentService;
import cn.luischen.service.site.SiteService;

public class BaseController_WGTest2 {

	@Mock
	private ContentService contentService;

	@Mock
	cn.luischen.service.meta.MetaService mock_MetaService;

	@Mock
	private SiteService siteService;

	@org.junit.Before
	public void setUp() throws Exception {
		// TODO: add additional set up code here
		try {
			MockitoAnnotations.initMocks(this);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

	@Test
	public void test_join_1() {
		BaseController unitspirit_mock_instance = PowerMockito.mock(BaseController.class);
		String[] arr = new String[] { "1", "3" };
		when(unitspirit_mock_instance.join(arr)).thenCallRealMethod();
		String strResult = unitspirit_mock_instance.join(arr);
		System.out.print("test_join_1:" + strResult);
		assertNull(strResult);
	}

	@Test

	public void test_join_0616_225759_090_5() throws Throwable {
		cn.luischen.controller.BaseController unitspirit_fixture = PowerMockito
				.mock(cn.luischen.controller.BaseController.class);
		cn.luischen.service.meta.impl.MetaServiceImpl mock_sub_caller_MetaServiceImpl = PowerMockito
				.mock(cn.luischen.service.meta.impl.MetaServiceImpl.class);
		// XXX test_join_0616_225759_090_5 service 没有注入
		Whitebox.setInternalState(unitspirit_fixture, mock_sub_caller_MetaServiceImpl);
		// generateForSubCallerCommon
		java.util.List<cn.luischen.dto.MetaDto> mock_result_List0 = JSON.parseArray(
				"[{\'count\':0,\'name\':\'MOCK使用矩阵\',\'description\':\'http://47.103.28.63:8080/admin/links\',\'mid\':45,\'sort\':1,\'type\':\'link\',\'slug\':\'http://47.103.28.63:8080/admin/links\'}]",
				cn.luischen.dto.MetaDto.class);
		PowerMockito.when(mock_sub_caller_MetaServiceImpl, "getMetaList", Mockito.any(String.class),
				Mockito.any(String.class), Mockito.any(int.class)).thenReturn(mock_result_List0);
		// getParamInitForCommon
		java.lang.String[] String_p_0 = JSON.parseObject("[\'http://47.103.28.63:8080/admin/links\']",
				java.lang.String[].class);// ClassName=cn/luischen/service/meta/MetaService MethodName=getMetaList
											// MethodDesc=(Ljava/lang/String;Ljava/lang/String;I)Ljava/util/List;
		when(mock_MetaService.getMetaList(any(java.lang.String.class), any(java.lang.String.class), any(int.class)))
				.thenReturn(new ArrayList());

		// CaseForSubCallMockImpl.collectCaseForNormal
		when(unitspirit_fixture.join(String_p_0)).thenCallRealMethod();
		java.lang.String unitspirit_result = unitspirit_fixture.join(String_p_0);
		System.out.println("unitspirit_check:test_join_0616_225759_090_5:" + JSON.toJSONString(unitspirit_result));
		java.lang.String result_expected = "http://47.103.28.63:8080/admin/links";
		assertEquals(JSON.toJSONString(unitspirit_result), JSON.toJSONString(result_expected));
	}
}